# coding=utf-8
#_author_: chanceyang
#date:2020/3/21

from handle.handle import Handle
from appium import webdriver
from time import sleep

def Handle_Install_Window(port,caps,install_btn):
    driver = webdriver.Remote("http://127.0.0.1:" + str(port) + "/wd/hub",caps)
    handle=Handle(driver)
    # 点掉安装弹窗
    for i in range(3):
        # ele=handle.wait_Ele("ID","android:id/button2")
        # ele = handle.wait_Ele("NAME", "继续安装")
        # ele=driver.find_element_by_name("继续安装")
        sleep(1)
        try:
            ele=handle.FUIE.by_Text(install_btn)
            if(ele!=None):
                ele.click()
                break
        except:
            pass
#点掉权限弹窗
    # count=right_button_times
    # for i in range(15):
    #     sleep(1)
    #     try:
    #         ele=handle.FUIE.by_Text(right_btn)
    #         if(ele!=None and count>0):
    #             ele.click()
    #             count -= 1
    #     except:
    #         pass
    #     finally:
    #         if count==0:
    #             break

